<strong>Note: don't forget to run <i>npm install</i> to install the javascript client</strong>
<h2>All Messages</h2>

<ul id="msgs"></ul>

<hr>

<input type="text" id="msg" placeholder="Enter Message" />
<input type="button" id="send" value="Send" />

@section scripts {
<script>
    $(function () {
        //we are connecting on secure connection to the signalR server
        const hubConnection = new signalR.HubConnection(
                   "https://localhost:5001/chathub", { logger: signalR.LogLevel.Information });
    
        hubConnection.start().catch(err => console.error);

        $("#send").click(function () {
            hubConnection.invoke('Send', $('#msg').val());
        });

        hubConnection.on('Send', data => {
            $('#msgs').append($('<li>').text(data));
        });
    });
</script>
}